package net.lesscoding.enums;

/**
 * @author eleven
 * @date 2024/10/31 8:33
 * @apiNote
 */
public enum Action {
    LOGIN(1),
    LOGOUT(2),
    CHAT(3),
    HEARTBEAT(4),
    JOIN_ROOM(5),
    LEAVE_ROOM(6),
    READY(7),
    START_GAME(8),
    PLAY_CARD(9),
    PASS(10),
    GAME_OVER(11),
    GAME_RESULT(12),
    ;

    private int code;

    Action(int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    public static Action getActionByCode(int code) {
        for (Action action : values()) {
            if (action.getCode() == code) {
                return action;
            }
        }
        return null;
    }
}
